#include <bits/stdc++.h>
using namespace std;

int d[100005], v[100005], a[100005], p[100005], nxtp[1000005];
bool vis[100005];

struct rgs
{
    int l, r;
}rg[100005];

bool cmp(rgs a, rgs b)
{
    return a.r < b.r;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T --)
    {
        memset(p, 0, sizeof p);
        int n, m, L, V;
        scanf("%d %d %d %d", &n, &m, &L, &V);
        for (int i = 1; i <= n; i ++)
        {
            scanf("%d %d %d", &d[i], &v[i], &a[i]);
        }
        for (int i = 1; i <= m; i ++)
        {
            scanf("%d", &p[i]);
        }
        sort(p + 1, p + 1 + m);
        int now = 1;
        for (int i = 0; i <= L; i ++)
        {
            if (i == p[now]) nxtp[i] = now ++;
            else nxtp[i] = now;
        }

        //How many cars are too fast?
        int cnt = 0;
        for (int i = 1; i <= n; i ++)
        {
            if (d[i] > p[m]) continue;
            if (a[i] == 0)
            {
                if (v[i] > V && d[i] <= p[m])
                {
                    cnt ++;
                    rg[cnt].l = nxtp[d[i]];
                    rg[cnt].r = m;
                }
            }
            else if (a[i] > 0)
            {
                int dis = p[m] - d[i];
                double iv = sqrt(v[i] * v[i] + 2 * a[i] * dis);
                if (iv > V)
                {
                    cnt ++;
                    rg[cnt].r = m;
                    if (V < v[i])
                    {
                        rg[cnt].l = nxtp[d[i]];
                        continue;
                    }
                    int point = ceil((V * V - v[i] * v[i]) / (2.0 * a[i])) + d[i];
                    rg[cnt].l = nxtp[point];
                }
            }
            else
            {
                double bkp = (-v[i] * v[i]) / (2.0 * a[i]) + d[i];
                int dis = p[nxtp[d[i]]] - d[i];
                if (d[i] + dis > bkp) continue;
                double iv = sqrt(v[i] * v[i] + 2 * a[i] * dis);
                if (iv > V)
                {
                    cnt ++;
                    rg[cnt].l = nxtp[d[i]];
                    int point = ceil((V * V - v[i] * v[i]) / (2.0 * a[i])) + d[i];
                    if (point > L) rg[cnt].r = m;
                    else rg[cnt].r = nxtp[point] - 1;
                }
            }
        }
        cout << cnt << " ";

        //How many detectors are useless?
        sort(rg + 1, rg + 1 + cnt, cmp);
        int uf = 0, lastr = 0;
        for (int i = 1; i <= cnt; i ++)
        {
            if (lastr >= rg[i].l) continue;
            uf ++, lastr = rg[i].r;
        }
        cout << m - uf << endl;
    }
    return 0;
}
